<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>倒计时</title>
    <style>
        div{
            width: 20px;
            height: 20px;
            background-color: red;
            color:black;
        }
    </style>
</head>
<body>
    <div id="a"></div>
</body>
</html>
<script>
    var aDIV = document.getElementById('a');
    var time = 5;
    var readtime;
    function get_time() {
        aDIV.innerHTML=time;
       time>0?time--:clearInterval(readtime);
    }
    readtime = setInterval(get_time, 1000);
</script>